package ljl.alg.wangzheng_camp.round1.bisection;

public class _744_next_letter {
    
    /**
     * 例子说比 'z' 大的是 'a' 我先写上吧
     * */
    public char nextGreatestLetter(char[] letters, char target) {
        if (letters[letters.length - 1] <= target) return letters[0];
        int l = 0, r = letters.length - 1;
        while (l < r) {
            int mid = (l + r) >>> 1;
            if (letters[mid] <= target) l = mid + 1;
            else r = mid;
        }
        return letters[l];
    }
}
